import Vue from 'vue';
import VueRouter from 'vue-router';
import login from '../views/login/index';
Vue.use(VueRouter);

const routes = [{
    path: '/',
    name: 'login',
    component: login,
    meta: {
      title: "登录",
      metaTitle:"loginin"
    },
  },
  {
    path: '*',
    name: '404',
    meta: {
      title: "404"
    },
    component: resolve => require(['@/views/features/404'], resolve),
  },
  {
    path: '/download',
    name: 'download',
    meta: {
      title: "下载",
      metaTitle:"downLoads"
    },
    component: resolve => require(['@/views/download/index'], resolve),
  },
  {
    path: '/pact/:id',
    name: 'pact',
    meta: {
      title: "协议",
      metaTitle:"pacts"
    },
    component: resolve => require(['@/views/features/pact'], resolve),
  },
  {
    path: '/pactList',
    name: 'pactList',
    meta: {
      title: "协议列表",
      metaTitle:"pactLists"
    },
    component: resolve => require(['@/views/features/pactList'], resolve),
  },
  {
    path: '/documentType',
    name: 'documentType',
    meta: {
      title: "证件类型",
      metaTitle:"docmentTypes"
    },
    component: resolve => require(['@/views/documentType/index'], resolve),
  },
  {
    path: '/mainlandCard',
    name: 'mainlandCard',
    meta: {
      title: "上传身份证",
      metaTitle:"mainCards"
    },
    component: resolve => require(['@/views/mainlandCard/index'], resolve),
  },
  {
    path: '/CAvideo',
    name: 'CAvideo',
    meta: {
      title: "CA录制视频",
      metaTitle:"CAVideos"
    },
    component: resolve => require(['@/views/CAVideo/index'], resolve),
  },
  {
    path: '/autograph',
    name: 'autograph',
    meta: {
      title: "确认签字",
      metaTitle:"graphs"
    },
    component: resolve => require(['@/views/autograph/index'], resolve),
  },
  {
    path: '/autoImg',
    name: 'autoImg',
    meta: {
      title: "确认签字",
      metaTitle:"graphImgs"
    },
    component: resolve => require(['@/views/autograph/autoImg'], resolve),
  },
  {
    path: '/custom',
    name: 'custom',
    meta: {
      title: "--"
    },
    component: resolve => require(['@/views/custom/index.vue'], resolve),
  },
  {
    path: '/verification',
    name: 'verification',
    meta: {
      title: "核实身份", // 主页面
      metaTitle:"verifications"
    },
    component: resolve => require(['@/views/verification/index'], resolve),
  },
  {
    path: '/CounterAddress',
    name: 'CounterAddress',
    meta: {
      title: "柜台核实",
      metaTitle:"CounterAddresss"
    },
    component: resolve => require(['@/views/verification/web/CounterAddress'], resolve),
  },
  {
    path: '/CounterOrder',
    name: 'CounterOrder',
    meta: {
      title: "预约见面",
      metaTitle:"CounterOrders"
    },
    component: resolve => require(['@/views/verification/web/CounterOrder'], resolve),
  },

  {
    path: '/OnlineAddress',
    name: 'OnlineAddress',
    meta: {
      title: "网上开户",
      metaTitle:"OnlineAddresss"
    },
    component: resolve => require(['@/views/verification/local/OnlineAddress'], resolve),
  },
  {
    path: '/OnlineRemit',
    name: 'OnlineRemit',
    meta: {
      title: "汇款通知",
      metaTitle:"OnlineRemits"
    },
    component: resolve => require(['@/views/verification/local/OnlineRemit'], resolve),
  },

  {
    path: '/examine',
    name: 'examine',
    meta: {
      title: "审核",
      metaTitle:"examines"
    },
    component: resolve => require(['@/views/examine/index'], resolve),
  },
  {
    path: '/verify',
    name: 'verify',
    meta: {
      title: "审核身份",
      metaTitle:"verifys"
    },
    component: resolve => require(['@/views/verify/index'], resolve),
  },
];
const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes,
  
});


router.beforeEach((to, from, next) => {
  if (!localStorage.getItem('token') && to.path != '/' && to.name !=='pact' && to.name !=='download') {
    next({ path: '/' });
    // location.reload()
  } else {
    next();
  }
});
export default router;
